package com.cloudptt.api.product.operator;

import android.content.Context;

import com.cloudptt.api.comm.CauseCont;
import com.cloudptt.api.product.func.SipOperator;
import com.cloudptt.api.product.log.Log;
import com.mcptt.db.DBAdapter;

public class CrscOperator extends SipOperator
{
	private final static String THIS_FILE = "CrscOperator";
//	private boolean isAuthorize_Data = false;

	private DBAdapter dbOperater = null;
	public CrscOperator(Context ctx, DBAdapter dbOperater)
	{
		super(ctx);
		this.dbOperater = dbOperater;
	}
	public int sendFuncLogx(boolean isActive,String uuId,String funcNum,boolean isForce,String initiateId)
	{
		Log.d(THIS_FILE, "sendFuncLogx isActive = " + isActive +  " uuId = " + uuId + " funcNum = " + funcNum + " isForce = " + isForce + " initiateId = " + initiateId);
		int result = checkFirst();
		if(CauseCont.OperateCheck_Suc != result)
		{
			return result;
		}
//		if(!isAuthorize_Data)
//		{
//			return CauseCont.OperateErr_NoAuthorize_Data;
//		}
		try
		{
			return service.sendPublishFuncLogx(isActive,uuId,funcNum,isForce,initiateId);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return CauseCont.OperateCheck_Sys_OperateException;
		}
	}

	public int sendFuncLogoutAll(String[] funcNumList)
	{
		Log.d(THIS_FILE, "sendFuncLogx funcNumList = " + funcNumList);
		int result = checkFirst();
		if(CauseCont.OperateCheck_Suc != result)
		{
			return result;
		}
//		if(!isAuthorize_Data)
//		{
//			return CauseCont.OperateErr_NoAuthorize_Data;
//		}
		try
		{
			return service.sendPublishFuncLogoutAll(funcNumList);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return CauseCont.OperateCheck_Sys_OperateException;
		}
	}

	public int subcribeFuncSelf()
	{
		Log.d(THIS_FILE, "subcribeFuncSelf");
		int result = checkFirst();
		if(CauseCont.OperateCheck_Suc != result)
		{
			return result;
		}
//		if(!isAuthorize_Data)
//		{
//			return CauseCont.OperateErr_NoAuthorize_Data;
//		}
		try
		{
			return service.subcribeFuncSelf();
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return CauseCont.OperateCheck_Sys_OperateException;
		}
	}
	public int subcribeFunc(String uuId,String funcNum)
	{
		Log.d(THIS_FILE, "subcribeFunc uuId = " + uuId + " funcNum = " + funcNum);
		int result = checkFirst();
		if(CauseCont.OperateCheck_Suc != result)
		{
			return result;
		}
//		if(!isAuthorize_Data)
//		{
//			return CauseCont.OperateErr_NoAuthorize_Data;
//		}
		try
		{
			return service.subcribeFunc(uuId,funcNum);
		}
		catch (Exception e)
		{
			e.printStackTrace();
			return CauseCont.OperateCheck_Sys_OperateException;
		}
	}
}
